<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/communication/ComPort.js" type="text/javascript"></script>
<script>

    //串口对象
    var comPort;

    /**
     * 初始化控件
     */
    function initActiveX() {
        try{
            alert("aa");
            comPort = new ComPort();
            comPort.comNum = 2;
            comPort.open();
            alert("init success");
        }catch (e) {
            console.log(e);
            alert(e);
        }
    }

    /**
     * 发送数据
     */
    function sendData() {
        comPort.sendData("Hello,World",function (data) {
            alert("sendData:"+data);
        });
        // comPort.sendData("Hello");
    }
</script>

<body>

    <input type="button" onclick="initActiveX()" value="initActiveX">
    <input type="button" onclick="sendData()" value="发送数据">

</body>
</html>